#ifndef QUEUE_H
#define QUEUE_H

#include <pthread.h>
#include <stddef.h>

// 队列节点结构
typedef struct QueueNode {
    void *data;
    struct QueueNode *next;
} QueueNode;

// 队列结构
typedef struct {
    QueueNode *front;
    QueueNode *rear;
    int size;
    int capacity;
    pthread_mutex_t mutex;
    pthread_cond_t not_empty;
    pthread_cond_t not_full;
} Queue;

// 队列相关函数声明
Queue *queueCreate(int capacity);
void queueDestroy(Queue *queue);
int queueEnqueue(Queue *queue, void *data, size_t dataSize);
void *queueDequeue(Queue *queue, size_t *dataSize);
void *queueTryDequeue(Queue *queue, size_t *dataSize);
int queueSize(Queue *queue);
void queueClear(Queue *queue);

#endif // QUEUE_H